﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MvcShop.Models.ViewDataModels
{
    public class ProductsViewData:ViewDataBase
    {
        #region ==== Property =====
        public int PageIndex { get; set; }
        public int Count { get; set; }
        public int Total { get; set; }
        public string KeyWord { get; set; }
        public PositionType PositionType{get;set;}

        public Category Category { get; set; }
        public IEnumerable<Category> Categories { get; set; }

        public Product Product { get; set; }
        public IEnumerable<Product> Products { get; set; }

        public Product_property Product_property { get; set; }
        public IEnumerable<Product_property> Product_properties { get; set; }

        public Product_propertys_content Product_propertys_content { get; set; }
        public IEnumerable<Product_propertys_content> Product_propertys_contents { get; set; }

        public Product_Image Product_Image { get; set; }
        public IEnumerable<Product_Image> Product_Images { get; set; }

        public Remark Remark { get; set; }
        public IEnumerable<Remark> Remarks { get; set; }

        public PPCModel PPCModel { get; set; }
        public IEnumerable<PPCModel> PPCModels { get; set; }

        public RemarkType RemarkType { get; set; }
        public IEnumerable<ProductsToRemarkModel> ProductsToRemarkModels { get; set; }
        #endregion

        #region ==== Methods ====
        public ProductsViewData WithPageIndex(int pageIndex)
        {
            this.PageIndex = pageIndex;
            return this;
        }

        public ProductsViewData WithCount(int count)
        {
            this.Count = count;
            return this;
        }

        public ProductsViewData WithTotal(int pageSize)
        {
            this.Total = Math.Max((this.Count + pageSize - 1) / pageSize, 1); ;
            return this;
        }

        public ProductsViewData WithKeyWord(string keyWord)
        {
            this.KeyWord = keyWord;
            return this;
        }

        public ProductsViewData WithPositionType(PositionType positionType)
        { 
            this.PositionType = positionType;
            return this;
        }
        
        public ProductsViewData WithCategory(Category category)
        {
            this.Category = category;
            return this;
        }

        public ProductsViewData WithCategories(IEnumerable<Category> categorise)
        {
            this.Categories = categorise;
            return this;
        }

        public ProductsViewData WithProduct(Product product)
        {
            this.Product = product;
            return this;
        }

        public ProductsViewData WithProducts(IEnumerable<Product> products)
        {
            this.Products = products;
            return this;
        }

        public ProductsViewData WithProduct_property(Product_property propery)
        {
            this.Product_property = propery;
            return this;
        }

        public ProductsViewData WithProduct_propertis(IEnumerable<Product_property> properies)
        {
            this.Product_properties = properies;
            return this;
        }

        public ProductsViewData WithProduct_propertys_content(Product_propertys_content content)
        {
            this.Product_propertys_content = content;
            return this;
        }

        public ProductsViewData WithProduct_propertys_contents(IEnumerable<Product_propertys_content> contents)
        {
            this.Product_propertys_contents = contents;
            return this;
        }

        public ProductsViewData WithProduct_Image(Product_Image image)
        {
            this.Product_Image = image;
            return this;
        }

        public ProductsViewData WithProduct_Images(IEnumerable<Product_Image> images)
        {
            this.Product_Images = images;
            return this;
        }

        public ProductsViewData WithRemark(Remark remark)
        {
            this.Remark = remark;
            return this;
        }

        public ProductsViewData WithRemarks(IEnumerable<Remark> remarks)
        {
            this.Remarks = remarks;
            return this;
        }

        public ProductsViewData WithPPCModel(PPCModel ppcModel)
        {
            this.PPCModel = ppcModel;
            return this;
        }

        public ProductsViewData WithPPCModels(IEnumerable<PPCModel> ppcModels)
        {
            this.PPCModels = ppcModels;
            return this;
        }

        public ProductsViewData WithRemarkType(RemarkType remarkType)
        {
            this.RemarkType = remarkType;
            return this;
        }

        public ProductsViewData WithProductsToRemarkModels(IEnumerable<ProductsToRemarkModel> productsToRemarkModels)
        {
            this.ProductsToRemarkModels = productsToRemarkModels;
            return this;
        }
        #endregion
    }

    /// <summary>
    /// 创建新的ProductsViewData类
    /// </summary>
    public static class ProductsView
    {
        public static ProductsViewData Data { get { return new ProductsViewData(); } }
    }
}
